﻿<UserControl x:Class="CAION2.Controls.CharacterPlace"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:controls="clr-namespace:CAION2.Controls"
             xmlns:resources="clr-namespace:CAION2.Properties"
             xmlns:viewModels="clr-namespace:CAION2.ViewModels"
             xmlns:converters="http://schemas.kent.boogaart.com/converters"
             x:Name="Control"
             Background="Transparent"
             MinHeight="10"
             MinWidth="10"
             IsEnabled="{Binding IsEnabled}"
             Visibility="{Binding Visible}"
             Opacity="{Binding Opacity}"
             ToolTip="{Binding Translate}">

    <UserControl.Resources>
        <ContextMenu x:Key="PlaceMenu">
            <MenuItem Command="{Binding DeletePlaceCommand}" 
                      Header="{x:Static resources:Resources.Manastones_MenuDelete}" />
        </ContextMenu>
    </UserControl.Resources>

    <UserControl.DataContext>
        <viewModels:ItemPlaceViewModel />
    </UserControl.DataContext>

    <UserControl.Style>
        <Style TargetType="{x:Type controls:CharacterPlace}">
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="BorderSize" Value="2" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </UserControl.Style>

    <Canvas Width="{Binding Width, ElementName=Control, Converter={converters:ExpressionConverter {}{0} - 2}}"
            Height="{Binding Height, ElementName=Control, Converter={converters:ExpressionConverter {}{0} - 2}}"
            HorizontalAlignment="Center"
            VerticalAlignment="Center"
            ContextMenu="{StaticResource PlaceMenu}">

        <Image Width="{Binding Width, ElementName=Control, Converter={converters:ExpressionConverter {}{0} - 2}}"
               Height="{Binding Height, ElementName=Control, Converter={converters:ExpressionConverter {}{0} - 2}}"
               HorizontalAlignment="Center"
               VerticalAlignment="Center"
               Source="{Binding Background,
                                Mode=OneWay,
                                UpdateSourceTrigger=PropertyChanged}"
               Stretch="Uniform" />

        <Image Width="{Binding Width, ElementName=Control, Converter={converters:ExpressionConverter {}{0} - 6}}"
               Height="{Binding Height, ElementName=Control, Converter={converters:ExpressionConverter {}{0} - 6}}"
               Margin="2,2,0,0"
               HorizontalAlignment="Center"
               VerticalAlignment="Center"
               Panel.ZIndex="1"
               Source="{Binding Icon,
                                Mode=OneWay,
                                UpdateSourceTrigger=PropertyChanged}"
               Stretch="Uniform" />

        <Border Width="{Binding Width, ElementName=Control, Converter={converters:ExpressionConverter {}{0} - 2}}"
                Height="{Binding Height, ElementName=Control, Converter={converters:ExpressionConverter {}{0} - 2}}"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                Panel.ZIndex="4"
                Background="{Binding RedBackground,
                                     Mode=OneWay,
                                     UpdateSourceTrigger=PropertyChanged}"
                BorderBrush="{DynamicResource Accent}"
                BorderThickness="{Binding BorderSize,
                                          ElementName=Control,
                                          Mode=OneWay}" />

    </Canvas>


</UserControl>
